package com.company;

public class AkabaNum {
    final static int ByteStep = 1024;

    public static String humanizeByteSize(long size) {
        double byteStep = AkabaNum.ByteStep;
        double remain = size;
        System.out.println("gotten size " + String.valueOf(size));
        String[] units = new String[]{"", "K", "M", "G"};
        int i = 0;
        while(remain >= byteStep) {
            i++;
            if (i >= units.length) {
                break;
            }
            remain = remain / byteStep;
        }
        String unit = units[i];
        return String.valueOf((double) Math.round(remain * 100) / 100) + unit;
    }
}
